package com.project.service;

import com.project.dao.NoticeMapper;
import com.project.entity.Notice;
import com.project.service.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: TateBrown
 * @date: 2018/5/26 14:37
 * @param:
 * @return:
 */
@Transactional(rollbackFor=Exception.class)
@Service
public class NoticeServiceImpl extends BaseService implements NoticeService {
    @Autowired
    private  NoticeMapper noticeMapper ;
    @Override
    public Notice findById(int id) {
        return noticeMapper.selectByPrimaryKey(id);
    }

    @Override
    public int modify(Notice notice) {
        return noticeMapper.updateByPrimaryKeySelective(notice);
    }

    @Override
    public int add(Notice notice) {
        return noticeMapper.insertSelective(notice);
    }

    @Override
    public int delete(int id) {
        return noticeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Notice> findAll() {
        return noticeMapper.selectAll();
    }

    /**
     * author: WheelChen
     * date: 2017/6/26
     * function: 分页条件查找
     *
     * @param notice
     * @return
     */
    @Override
    public List<Notice> findByCondition(Notice notice) {
        return noticeMapper.selectByCondition(notice);
    }
}
